import {reqAddressInfo,reqOrderInfo,reqadressinfo} from "@/api"
const state = { 
    addressInfo:[],
    orderInfo:{},
    addressinfo:{}
};
const mutations = {
    GETUSERADDRESS(state,addressInfo){
        state.addressInfo = addressInfo
    },
    GETORDERINFO(state,orderInfo){
        state.orderInfo = orderInfo
    },
    GETADDRESSINFO(state,addressinfo){
        state.addressinfo = addressinfo
    }
};
const actions = {
    //获取用户地址信息
    async getUserAddress({commit}){
        let result = await reqAddressInfo()
        console.log("用户地址",result)
        if(result.code == 200){
            commit('GETUSERADDRESS',result.data)
        }
    },
    //mock获取用户地址信息
    async getAddressinfo({commit}){
        let result = await reqadressinfo()
        console.log("mock用户地址",result)
        if(result.code == 200){
            commit('GETADDRESSINFO',result.data)
        }
    },
    //获取商品清单
    async getOrderInfo({commit}){
        let result = await reqOrderInfo()
        console.log("商品清单",result)
        if(result.code == 200){
            commit('GETORDERINFO',result.data)
        }
    }
}; 
const getters = {

}
export default{
    state,
    mutations,
    actions,
    getters
}